home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / CodeFragments.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  8.5 KB  |  303 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CodeFragments.h
  3.  
  4.      Contains:    Code Fragment Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CODEFRAGMENTS__
  21. #define __CODEFRAGMENTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __FILES__
  30. #include <Files.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <OSUtils.h>                                        */
  34. /*        #include <Memory.h>                                        */
  35. /*    #include <Finder.h>                                            */
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_ALIGN_SUPPORTED
  42. #pragma options align=mac68k
  43. #endif
  44.  
  45. #if PRAGMA_IMPORT_SUPPORTED
  46. #pragma import on
  47. #endif
  48.  
  49.  
  50. enum {
  51.     kCFragResourceType            = 'cfrg',
  52.     kCFragResourceID            = 0,
  53.     kCFragLibraryFileType        = 'shlb'
  54. };
  55.  
  56. typedef OSType CFragArchitecture;
  57.  
  58.  
  59. enum {
  60.     kPowerPCCFragArch            = 'pwpc',
  61.     kMotorola68KCFragArch        = 'm68k',
  62.     kAnyCFragArch                = 0x3F3F3F3F
  63. };
  64.  
  65. #if GENERATINGPOWERPC
  66. enum {
  67.     kCurrentCFragArch            = kPowerPCCFragArch
  68. };
  69.  
  70. #endif
  71. #if GENERATING68K    
  72. enum {
  73.     kCurrentCFragArch            = kMotorola68KCFragArch
  74. };
  75.  
  76. #endif
  77. typedef UInt32 CFragConnectionID;
  78.  
  79. typedef UInt32 CFragClosureID;
  80.  
  81. typedef UInt32 CFragContextID;
  82.  
  83. typedef UInt32 CFragContainerID;
  84.  
  85. typedef UInt32 CFragLoadOptions;
  86.  
  87.  
  88. enum {
  89.     kLoadCFrag                    = 0x01,                            /* Try to use existing copy, load if not found.*/
  90.     kFindCFrag                    = 0x02,                            /* Try find an existing copy, don't load if not found.*/
  91.     kNewCFragCopy                = 0x05,                            /* Load a new copy whether one already exists or not.*/
  92.     kInplaceCFrag                = 0x80                            /* Use data sections directly in the container.*/
  93. };
  94.  
  95. enum {
  96.     kUnresolvedCFragSymbolAddress = 0
  97. };
  98.  
  99. typedef UInt8 CFragSymbolClass;
  100.  
  101.  
  102. enum {
  103.     kCodeCFragSymbol            = 0,
  104.     kDataCFragSymbol            = 1,
  105.     kTVectorCFragSymbol            = 2,
  106.     kTOCCFragSymbol                = 3,
  107.     kGlueCFragSymbol            = 4
  108. };
  109.  
  110. typedef UInt8 CFragUsage;
  111.  
  112.  
  113. enum {
  114.     kImportLibraryCFrag            = 0,                            /* Standard CFM import library.*/
  115.     kApplicationCFrag            = 1,                            /* Macintosh application.*/
  116.     kDropInAdditionCFrag        = 2                                /* Private extension to an application or library.*/
  117. };
  118.  
  119. enum {
  120.     kIsCompleteCFrag            = 0,                            /* A "base" fragment, not an update.*/
  121.     kFirstCFragUpdate            = 1                                /* The first update, others are numbered 2, 3, ...*/
  122. };
  123.  
  124. typedef UInt8 CFragLocatorKind;
  125.  
  126.  
  127. enum {
  128.     kMemoryCFragLocator            = 0,                            /* Container is already addressable.*/
  129.     kDataForkCFragLocator        = 1,                            /* Container is in a file's data fork.*/
  130.     kResourceCFragLocator        = 2,                            /* Container is in a file's resource fork.*/
  131.     kByteStreamCFragLocator        = 3                                /* Container is in a given file fork as a byte stream.*/
  132. };
  133.  
  134. #define IsFileLocation(where)     \
  135.     ( ((where) == kDataForkCFragLocator)    ||  \
  136.     ((where) == kResourceCFragLocator)    ||  \
  137.     ((where) == kByteStreamCFragLocator) )
  138. enum {
  139.     kCFragGoesToEOF                = 0
  140. };
  141.  
  142. struct CFragOldMemoryLocator {
  143.     LogicalAddress                    address;
  144.     UInt32                            length;
  145.     Boolean                            inPlace;
  146.     UInt8                            reserved3a[3];                /* ! Do not use this!*/
  147. };
  148.  
  149. typedef struct CFragOldMemoryLocator CFragOldMemoryLocator;
  150.  
  151. struct CFragHFSDiskFlatLocator {
  152.     FSSpecPtr                        fileSpec;
  153.     UInt32                            offset;
  154.     UInt32                            length;
  155. };
  156. typedef struct CFragHFSDiskFlatLocator CFragHFSDiskFlatLocator;
  157.  
  158. /* ! This must have a file specification at the same offset as a data fork locator!*/
  159. struct CFragHFSSegmentedLocator {
  160.     FSSpecPtr                        fileSpec;
  161.     OSType                            rsrcType;
  162.     SInt16                            rsrcID;
  163.     UInt16                            reserved2a;                    /* ! Do not use this!*/
  164. };
  165.  
  166. typedef struct CFragHFSSegmentedLocator CFragHFSSegmentedLocator;
  167.  
  168. struct CFragHFSLocator {
  169.     SInt32                            where;                        /* Really of type CFragLocatorKind.*/
  170.     union {
  171.         CFragHFSDiskFlatLocator            onDisk;                    /* First so debugger shows this form.*/
  172.         CFragOldMemoryLocator            inMem;
  173.         CFragHFSSegmentedLocator        inSegs;
  174.     } u;
  175. };
  176.  
  177. typedef struct CFragHFSLocator CFragHFSLocator;
  178.  
  179. typedef CFragHFSLocator *CFragHFSLocatorPtr;
  180.  
  181. /* -------------------------------------------------------------------------------------------*/
  182. /* The parameter block passed to fragment initialization functions.  The locator and name*/
  183. /* pointers are valid only for the duration of the initialization routine.  I.e. if you want*/
  184. /* to save the locator or name, save the contents, not the pointers.  Initialization routines*/
  185. /* take one parameter, a pointer to the parameter block, and return a success/failure result.*/
  186. /* ! Note that the initialization function returns an OSErr.  Any result other than noErr will*/
  187. /* ! cause the entire load to be aborted at that point.*/
  188. struct CFragInitBlock {
  189.     CFragContextID                    contextID;
  190.     CFragClosureID                    closureID;
  191.     CFragConnectionID                connectionID;
  192.     CFragHFSLocator                    fragLocator;
  193.     StringPtr                        libName;
  194.     UInt32                            reserved4a;                    /* ! Do not use this!*/
  195.     UInt32                            reserved4b;                    /* ! Do not use this!*/
  196.     UInt32                            reserved4c;                    /* ! Do not use this!*/
  197.     UInt32                            reserved4d;                    /* ! Do not use this!*/
  198. };
  199. typedef struct CFragInitBlock CFragInitBlock;
  200.  
  201. typedef CFragInitBlock *CFragInitBlockPtr;
  202.  
  203. typedef pascal OSErr CFragInitFunction(const CFragInitBlock *theInitBlock);
  204. typedef pascal void CFragTermRoutine(void);
  205. typedef CFragInitFunction *CFragInitFunctionPtr;
  206.  
  207. typedef CFragTermRoutine *CFragTermRoutinePtr;
  208.  
  209. /* §*/
  210. /* ===========================================================================================*/
  211. /* Routines*/
  212. /* ========*/
  213. extern pascal OSErr GetSharedLibrary(ConstStr63Param libName, OSType archType, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  214.  THREEWORDINLINE(0x3F3C, 0x0001, 0xAA5A);
  215. extern pascal OSErr GetDiskFragment(const FSSpec *fileSpec, UInt32 offset, UInt32 length, ConstStr63Param fragName, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  216.  THREEWORDINLINE(0x3F3C, 0x0002, 0xAA5A);
  217. extern pascal OSErr GetMemFragment(void *memAddr, UInt32 length, ConstStr63Param fragName, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  218.  THREEWORDINLINE(0x3F3C, 0x0003, 0xAA5A);
  219. extern pascal OSErr CloseConnection(CFragConnectionID *connID)
  220.  THREEWORDINLINE(0x3F3C, 0x0004, 0xAA5A);
  221. extern pascal OSErr FindSymbol(CFragConnectionID connID, ConstStr255Param symName, Ptr *symAddr, CFragSymbolClass *symClass)
  222.  THREEWORDINLINE(0x3F3C, 0x0005, 0xAA5A);
  223. extern pascal OSErr CountSymbols(CFragConnectionID connID, long *symCount)
  224.  THREEWORDINLINE(0x3F3C, 0x0006, 0xAA5A);
  225. extern pascal OSErr GetIndSymbol(CFragConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, CFragSymbolClass *symClass)
  226.  THREEWORDINLINE(0x3F3C, 0x0007, 0xAA5A);
  227. #if OLDROUTINENAMES
  228. typedef CFragConnectionID ConnectionID;
  229.  
  230. typedef CFragLoadOptions LoadFlags;
  231.  
  232. typedef CFragSymbolClass SymClass;
  233.  
  234. typedef CFragOldMemoryLocator MemFragment;
  235.  
  236. typedef CFragHFSDiskFlatLocator DiskFragment;
  237.  
  238. typedef CFragHFSSegmentedLocator SegmentedFragment;
  239.  
  240. typedef CFragHFSLocator FragmentLocator;
  241.  
  242. typedef CFragHFSLocatorPtr FragmentLocatorPtr;
  243.  
  244. typedef CFragInitBlock InitBlock;
  245.  
  246. typedef CFragInitBlockPtr InitBlockPtr;
  247.  
  248. typedef CFragInitFunction ConnectionInitializationRoutine;
  249.  
  250. typedef CFragTermRoutine ConnectionTerminationRoutine;
  251.  
  252.  
  253. enum {
  254.     kPowerPCArch                = kPowerPCCFragArch,
  255.     kMotorola68KArch            = kMotorola68KCFragArch,
  256.     kAnyArchType                = kAnyCFragArch,
  257.     kNoLibName                    = 0,
  258.     kNoConnectionID                = 0,
  259.     kLoadLib                    = kLoadCFrag,
  260.     kFindLib                    = kFindCFrag,
  261.     kLoadNewCopy                = kNewCFragCopy,
  262.     kUseInPlace                    = kInplaceCFrag,
  263.     kCodeSym                    = kCodeCFragSymbol,
  264.     kDataSym                    = kDataCFragSymbol,
  265.     kTVectSym                    = kTVectorCFragSymbol,
  266.     kTOCSym                        = kTOCCFragSymbol,
  267.     kGlueSym                    = kGlueCFragSymbol,
  268.     kInMem                        = kMemoryCFragLocator,
  269.     kOnDiskFlat                    = kDataForkCFragLocator,
  270.     kOnDiskSegmented            = kResourceCFragLocator,
  271.     kIsLib                        = kImportLibraryCFrag,
  272.     kIsApp                        = kApplicationCFrag,
  273.     kIsDropIn                    = kDropInAdditionCFrag,
  274.     kFullLib                    = kIsCompleteCFrag,
  275.     kUpdateLib                    = kFirstCFragUpdate,
  276.     kWholeFork                    = kCFragGoesToEOF,
  277.     kCFMRsrcType                = kCFragResourceType,
  278.     kCFMRsrcID                    = kCFragResourceID,
  279.     kSHLBFileType                = kCFragLibraryFileType,
  280.     kUnresolvedSymbolAddress    = kUnresolvedCFragSymbolAddress
  281. };
  282.  
  283. enum {
  284.     kPowerPC                    = kPowerPCCFragArch,
  285.     kMotorola68K                = kMotorola68KCFragArch
  286. };
  287.  
  288. #endif
  289.  
  290. #if PRAGMA_IMPORT_SUPPORTED
  291. #pragma import off
  292. #endif
  293.  
  294. #if PRAGMA_ALIGN_SUPPORTED
  295. #pragma options align=reset
  296. #endif
  297.  
  298. #ifdef __cplusplus
  299. }
  300. #endif
  301.  
  302. #endif /* __CODEFRAGMENTS__ */
  303.